Ext.onReady(function(){
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	var columns = [
	    { id: 'name', header: 'Name', dataIndex: 'name__c', width: 100, type:'string'}, 
	    { header: 'Prefix', dataIndex: 'prefix', width: 60, type:'string'},
        { header: 'Active', dataIndex: 'active', type:'boolean'},
	    { header: 'Start Date', dataIndex: 'startdate', xtype: 'datecolumn'},
	    { header: 'End Date', dataIndex: 'enddate', xtype: 'datecolumn'},
	    { header: 'Description', dataIndex: 'desc', width: 220, type: 'string' }
	];
    var recordType = [
        {name: 'id__c',mapping:'id__c',type:'int'},
        {name: 'name__c',mapping:'name__c',type:'string'},
        { name: 'prefix', mapping: 'prefix', type: 'string' },
        {name: 'active',mapping:'active',type:'boolean'},
        {name: 'startdate',mapping:'startdate',type:'date'},
        {name: 'enddate',mapping:'enddate',type:'date'},
        { name: 'desc', mapping: 'desc', type: 'string' },
        { name: 'objecttype', mapping: 'objecttype', type: 'string' }
    ];
    api = {
        read : 'Product.aspx?action=read', 
        create : 'Product.aspx?action=create',
        update  : 'Product.aspx?action=update', 
        destroy : 'Product.aspx?action=destroy',
    };
    var formConfig = { title: 'New Product',
        items: [{fieldLabel: 'Name', name: 'name', allowBlank:false},
            {fieldLabel: 'Prefix',name: 'last'},
            {fieldLabel: 'Active',name: 'active'}, 
            {fieldLabel: 'StartDate',name: 'startDate'},
            {fieldLabel: 'EndDate',name: 'endDate'},
            {fieldLabel: 'Description',name: 'desc',vtype:'email'}, 
            {fieldLabel: 'Time',name: 'time',minValue: '8:00am',maxValue: '6:00pm'}
        ]
    }
    var gridPanel = new ScrumEditorGridPanel({id: 'grid-panel',
        storeConfig: {proxyConfig: {url: 'Product.aspx', api: api}, readerConfig: {recordType: recordType}, writerConfig: {api: api}},
        cmConfig: {columns: columns},
        newPwConfig: {url:'save-form.php',formConfig: formConfig}
    });
    var viewport = new DefaultScrumViewport({
        center : {title: 'Product List', gridPanel: gridPanel}
    });
});
